﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PartsDebtlLookUpList.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.PartsModel.PartsDebtlLookUpList" %>

<form id="pagerForm" method="post" action="PartsModel/PartsDebtlLookUpList.aspx">
<input type="hidden" name="CardCode" value="<%=CardCode %>" />
<input type="hidden" name="Comments" value="<%=Comments %>" />
<input type="hidden" name="orderField" value="<%=orderField %>" />
<input type="hidden" name="orderDirection" value="<%=orderDirection %>" />
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="20" />
</form>
<form id="form1" runat="server" method="post" action="PartsModel/PartsDebtlLookUpList.aspx" onsubmit="return dialogSearch(this);">
<div class="pageHeader">
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td>
                    <input type="hidden" name="CardCode" value="<%=CardCode %>" />
                    备注： <input name="Comments" type="text" value="<%=Comments %>"  />
                </td>
                <td>
                     <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div>
                            </li>
                        </ul>
                    </div>
                </td>
                <td width="330px">&nbsp;</td>
                <td width="100px">已选冲帐金额：</td>
                <td width="100px">
                <input id="PartsDebtLookUpListShowTotalMoney" readonly value="0" />
                可用:<span style="color:red;" id="PartsDebtLookUpListShowTotalMoneyCanUse">0.0</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="pageContent ">
    <asp:repeater id="rpMenu" runat="server">
        <HeaderTemplate>
        <table class="list PartsDebtLookUpListTable" width="100%" layouth="60" targetType="dialog">
        <thead>
            <tr  >                
                <th width="100">经销商</th>
                <th width="80" <%=GetDataListOrder("SaleDate") %>>销售日期</th>
                <th width="100">销售金额</th>
                <th width="80" <%=GetDataListOrder("ReceivedAmount") %>>已付</th>                
                <th width="80" >未付</th> 
                <th width="80" <%=GetDataListOrder("DueDate") %>>到期日</th> 
                <th width="60">本次冲帐</th> 


                <th width="70">操作</th>             
            </tr>
        </thead> 
        <tbody>
        </HeaderTemplate>
        <ItemTemplate>
            <tr id="PartsDebtLookUpListTableFTradeAgeId<%# Eval("DebtId") %>" >
                <td><%# Eval("CardName")%></td>
				<td><%# Eval("SaleDate")%></td>
                <td><%# FormatDecimalToStrings(Eval("SalesAmount"),"N")%></td>				
				<td><%# FormatDecimalToStrings(Eval("ReceivedAmount"),"N")%></td>
                <td><%# FormatDecimalToStrings(Eval("WeiShouAmount"),"N")%></td>
                <td><%# Convert.ToDateTime( Eval("DueDate")).ToString("yyyy-MM-dd")%></td>              
                <td>
                    <input class="BalanceMoney inputFloat"  id="BalanceMoney<%# Eval("DebtId")%>" maxmoney="<%# Convert.ToDecimal(Eval("WeiShouAmount"))%>" value="<%# Convert.ToDecimal(Eval("WeiShouAmount")) %>" />
                </td>               
			    <td>
					<a class="btnSelect" title="新增" href="javascript:onPartsDebtSelectAdd('#BalanceMoney<%# Eval("DebtId")%>',{DebtId:'<%# Eval("DebtId") %>', CardName:'<%# Eval("CardName")%>',SaleDate:'<%# Convert.ToDateTime( Eval("SaleDate")).ToString("yyyy-MM-dd") %>',SalesAmount:'<%# Eval("SalesAmount")  %>',ReceivedAmount:'<%# Eval("ReceivedAmount") %>',WeiShouAmount:'<%# Eval("WeiShouAmount") %>',DueDate:'<%# Convert.ToDateTime( Eval("DueDate")).ToString("yyyy-MM-dd") %>',CreateDate:'<%=System.DateTime.Now.ToString("yyyy-MM-dd") %>'})" title="查找带回">选择</a>
				    <a  class="btnDel" title="删除" href="javascript:void(0);" DebtId="<%#  Eval("DebtId") %>" style="dispaly:none;">删除</a>
                </td>
			</tr>
        </ItemTemplate>
        <FooterTemplate>
            </tbody>
         </table>
        </FooterTemplate>
    </asp:repeater>
    <script type="text/javascript">
        $(document).ready(function () {
            $("table.PartsDebtLookUpListTable").find("input.BalanceMoney").blur(function () {
                var $maxmoney = parseFloat($(this).attr("maxmoney"));
                var $inputmoney = parseFloat($(this).val());
//                if ($inputmoney <= 0) {
//                    alert("你所输入的冲帐金额小于0,请重输");
//                    $(this).val("0");
//                    return false;
//                }
                if ($inputmoney > $maxmoney) {
                    alert("你所输入的冲帐金额大于可用金额[" + $maxmoney + "],请重输");
                    $(this).val($maxmoney)
                    return false;
                }
            }).end().find("a.btnDel").click(function () {
                var $DebtId = $(this).attr("DebtId");
                onPartsDebtSelectAddDelete($("#PartsBalanceAdd_AddBalanceList_Row" + $DebtId).find("a"));
                var $row = $(this).closest("tr");
                //$row.find("#BalanceMoney" + $FTradeAgeId).val(0);
                $row.css("color", "#000").find("input").removeAttr("readonly");
              //  $row.find("#FXLPay_" + $FTradeAgeId).val("0");
            //    $row.find("#FXLPayShow_" + $FTradeAgeId).html("");

                $(this).hide();
                $(this).closest("td").find("a.btnSelect").show();
                //$row.find("a.btnSelectFXLPay").show();
                proccessTotalMoney();
            }).hide();

            function proccessTotalMoney() {
                $("#PartsDebtLookUpListShowTotalMoney").val(0);
                //处理已添加
                var $AddBalanceListTbody = $("#PartsBalanceAdd_AddBalanceList").find("tbody");
                //处理已选择
                $AddBalanceListTbody.find("tr").each(function () {
                    var $DebtId = $(this).find("input[name='DebtId']").val();
                    var $BalanceMoney = $(this).find("input[name='BalanceMoney']").val();
                    var $totalmoney = $("#PartsDebtLookUpListShowTotalMoney").val();                 


                    var rowExist = $("table.PartsDebtLookUpListTable").find("#PartsDebtLookUpListTableFTradeAgeId" + $DebtId).attr("id");
                    if (rowExist != undefined) {
                        var $row = $("table.PartsDebtLookUpListTable").find("#PartsDebtLookUpListTableFTradeAgeId" + $DebtId);
                        $row.find("#BalanceMoney" + $DebtId).val($BalanceMoney);
                    

                        $row.css("color", "red").find("input").attr("readonly", true);
                        $row.find("a.btnSelectFXLPay").hide();
                        $row.find("a.btnSelect").hide();
                        $row.find("a.btnDel").show();
                        //return;
                    }
                    $("#PartsDebtLookUpListShowTotalMoney").val(parseFloat($totalmoney) + parseFloat($BalanceMoney));

                })
                $("#PartsDebtLookUpListShowTotalMoneyCanUse").html(parseFloat($("#PartsBalanceAdd_ShengYuJinE").val()) - parseFloat($("#PartsDebtLookUpListShowTotalMoney").val()));
            }

            proccessTotalMoney();

        })
       

    </script>
     <div class="panelBar">
        <div class="pages">
            <span>显示</span>
            <select class="combox" name="numPerPage" onchange="dialogPageBreak({numPerPage:this.value})">
               <%=SetnumPerPage() %>
            </select>
            <span>条，共<%=TotalCount%>条</span>
        </div>
        <div class="pagination" targettype="dialog" totalcount="<%=TotalCount%>" numperpage="<%=numPerPage %>"
            pagenumshown="10" currentpage="<%=pageNum %>">
        </div>
    </div>
</div>
</form>
